package com.taxshare.mybatis.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

import java.util.Properties;

@Configuration
public class MybatisPlusConfig {
	
	/**
	 * mybatis-plus分页插件
	 */
	@Bean
	public PaginationInterceptor paginationInterceptor() {
		PaginationInterceptor page = new PaginationInterceptor();
		page.setDialectType(DbType.POSTGRE_SQL.getDb());
		return page;
	}

	/**
	 * 打印 sql
	 */
	@Bean
	@Profile(value = "dev")
	public PerformanceInterceptor performanceInterceptor() {
		PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
		// 格式化sql语句
		Properties properties = new Properties();
		properties.put("format", "false");
		properties.put("kingbaseES","kingbase");
		performanceInterceptor.setProperties(properties);
		return performanceInterceptor;
	}
}